package com.lagou.framework.factory;

import javax.servlet.ServletContainerInitializer;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import java.util.Set;

/**
 * 注：并非通过SPI方式来触发，具体参考 TomcatWebServerFactory
 */
public class TomcatStarter implements ServletContainerInitializer {

    private final DemoServletContextInitializer[] initializers;

    public TomcatStarter(DemoServletContextInitializer[] initializers) {
        this.initializers = initializers;
    }

    @Override
    public void onStartup(Set<Class<?>> c, ServletContext servletContext) throws ServletException {
        for (DemoServletContextInitializer initializer : initializers) {
            initializer.onStartup(servletContext);
        }
    }

}
